/*
 * @Author: jixuanyu
 * @Date: 2022-04-11 18:12:55
 * @LastEditors: jixuanyu
 * @Description: VitePress配置文件，用于配置静态页
 */

import config from './config/index.js'
const {navbar, sidebar, plugins} = config
import {defaultTheme, defineUserConfig} from 'vuepress'
import {path} from '@vuepress/utils'
import {viteBundler} from '@vuepress/bundler-vite'
import {backToTopPlugin} from '@vuepress/plugin-back-to-top'
import {registerComponentsPlugin} from '@vuepress/plugin-register-components'
import {searchPlugin} from '@vuepress/plugin-search'
import useJsx from '@vitejs/plugin-vue-jsx'
export default defineUserConfig({
  lang: 'zh-CN',
  head: [['link', {rel: 'icon', href: '/logo.png'}]],
  title: 'ZRAR-UI',
  description: '基于ant-design-vue定制的UI控件',
  // 主题和它的配置
  port: 5510,
  open: false,
  theme: defaultTheme({
    logo: '/logo.png',
    navbar: navbar,
    sidebar: sidebar,
    sidebarDepth: 1,
    repo: 'http://192.168.0.53:7000/front/zrar-ui',
    repoLabel: 'GitLab'
  }),
  markdown: {
    extractHeaders: {
      level: [2]
    },
    importCode: {
      handleImportPath: (str) =>
        str.replace(/^@components/, path.resolve(__dirname, './components/'))
    }
  },
  alias: {
    '@': path.resolve(__dirname, '../../src')
  },
  bundler: viteBundler({
    viteOptions: {
      plugins: [useJsx()]
    }
  }),
  plugins: [
    registerComponentsPlugin({
      // componentsDir: path.resolve(__dirname, './components/'),
      components: plugins
    }),
    backToTopPlugin(),
    searchPlugin({
      locales: {
        '/': {
          placeholder: '搜索'
        }
      }
    })
  ]
})
